<?php require_once(dirname(__FILE__) . '/../include/config.inc.php');
require_once "function.php";

/*
进度：
0 已经撤单
3 待接单
4 工程师接单
5 项目经理竣工申请
6 管理员发起验收
*/
$uid = $_SESSION['uid'];
$userInfo = "";
if (isset($uid)) {

    //有session 从数据库中读取用户名信息
    //$openid_str=$_SESSION['openid'];
    $sql = "SELECT u.*,g.groupname  as groupname FROM `#@__user` as u 
				   left join `#@__usergroup` as g  on u.level=g.id  
				   WHERE u.id='$uid'  ";
    $row = $dosql->GetOne($sql);
    if (is_array($row) && isset($row['id'])) {
        // 返回用户 id
        $id = $row['id'];
        $_SESSION['id'] = $id;
        $userInfo = $row;
        $level = intval($row['level']);
        $isadmin = intval($row['isadmin']);
    }
}

if ($level > 5) {
    exit();
}


$projectid = empty($projectid) ? "" : intval($projectid);
if (isset($projectid)) {


    $row = $dosql->GetOne("SELECT * FROM `#@__project`  WHERE id='$projectid'  AND is_delete=0 ");
    if (is_array($row) && isset($row['id'])) {
        $jindu2 = intval($row['jindu']);
        $signIn = intval($row['signIn']);
        $pmid = $row['pmid'];
        $pmid2 = $row['pmid2'];
        $old_manageid = $row['manageid'];

        $project_plan=$row['planpicurls'];


        $dosql->Execute("SELECT `id` FROM `#@__project_log` WHERE  orderid='$projectid' and `jindu`=4  and signIn=1 ", 2);
        $count2 = $dosql->GetTotalRow(2); //已经签到过


        // 返回工单数据
        /*
        进度：
        0 已经撤单
        1 报修成功
        2 客服已经联系
        3 系统已经派单
        4 工程师接单
        5 维修完成
        6 已经评价
        */
        $op_str = "";
        //判断是否是该工单的执行人
        if ($uid == $pmid || $uid == $pmid2) {
            if ($jindu2 == 3) {
                $op_str = '
			<div class="weui-flex__item">
			<div class="placeholder"><a class="weui-btn weui-btn_primary" id="jiedan_btn"  href="javascript:" onClick="jiedan(' . $row['id'] . ')"><i class="fa fa-thumb-tack" aria-hidden="true"></i>    接单</a></div>
			</div>';
                if ($isadmin == 1) {
                    $op_str .= '
			<div class="weui-flex__item">
			<div class="placeholder"><a class="weui-btn weui-btn_warn" id="jiedan_btn"  href="javascript:" onClick="chedan(' . $row['id'] . ')"><i class="fa fa-thumb-tack" aria-hidden="true"></i>    工程撤单</a></div>
			</div>';
                }


            } elseif ($jindu2 == 4) {

                if ($signIn == 1) {
                    $op_str = '<div class="weui-flex__item"><div class="placeholder"><a class="weui-btn weui-btn_warn" href="javascript:;" onclick="qiantui2(' . $row['id'] . ')" ><i class="fa fa-pencil" aria-hidden="true"></i>  中途人员签退</a></div></div>';
                }
                //如果没有签到 可以撤单
                if ($count2 == 0) {
                    $op_str .= '
			<div class="weui-flex__item">
			<div class="placeholder"><a class="weui-btn weui-btn_warn" id="jiedan_btn"  href="javascript:" onClick="chedan(' . $row['id'] . ')"><i class="fa fa-thumb-tack" aria-hidden="true"></i>    工程撤单</a></div>
			</div>';
                }


            }


        }


        //施工图纸
        $pic_lists = "";
        $previewImage_url = array();
        if ($row['picfiles'] != "") {
            $picurl_arr = json_decode($row['picfiles'], TRUE);
            for ($i = 0; $i < count($picurl_arr); $i++) {
                $previewImage_url[] = $picurl_arr[$i];
                $pic_lists .= '<li class="weui-uploader__file" style="background-image:url(' . $picurl_arr[$i] . ')"><img src="' . $picurl_arr[$i] . '" width="0"/></li>';
            }
        }        
        
        //施工计划
        $plan_pic_lists = "";
        $previewImage_url = array();
        if ($row['planpicurls'] != "") {
            $plan_picurl_arr = json_decode($row['planpicurls'], TRUE);
            for ($i = 0; $i < count($plan_picurl_arr); $i++) {
                $previewImage_url[] = $plan_picurl_arr[$i];
                $plan_pic_lists .= '<li class="weui-uploader__file" style="background-image:url(' . $plan_picurl_arr[$i] . ')"><img src="' . $plan_picurl_arr[$i] . '" width="0"/></li>';
            }
        }
        
        

        //完修 图片
        $over_picurls = $row['over_picurls'];
        $over_remark = $row['over_remark'];
        $fee = $row['fee'];


    } else {
        echo "<script>alert('任务不存在或者已经删除！')</script>";
        exit();
    }
}
?>
    <!DOCTYPE html>
    <html>
    <head>
        <title>工程详情--<?php echo $cfg_webname; ?></title>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="description" content="<?php echo $cfg_webname; ?>">
        <link rel="stylesheet" href="lib/weui.min.css">
        <link rel="stylesheet" href="css/jquery-weui.css">
        <link rel="stylesheet" href="css/font-awesome.min.css">
        <link rel="stylesheet" href="css/demos.css?v=20211218.1626">

        <link rel="stylesheet" href="ui/css/bootstrap.css">
        <link rel="stylesheet" href="ui/css/demos.css?v=1.6.5.12">

    </head>

<body ontouchstart>
<style>
    .m_list label { width: 33%; float: left;}

    .m_list p {margin: 0}

    .m_list .weui-cell {padding: 10px 0}

    .weui-label { width: 85px; font-size: 14px;}

    .form-control {
        display: block;
        width: 90%;
        height: 25px;
        padding: 6px 12px;
        font-size: 14px;
        line-height: 1.42857143;
        color: #555;
        background-color: #fff;
        background-image: none;
        border: 1px solid #ccc;
        border-radius: 4px;
        -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
        box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075);
        -webkit-transition: border-color ease-in-out .15s, -webkit-box-shadow ease-in-out .15s;
        -o-transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
        transition: border-color ease-in-out .15s, box-shadow ease-in-out .15s;
    }

    .w120 {width: 120px;}

    .weui-cell_select {
        padding: 10px 15px;
    }

    .content { width: 100%; height: 90px;}
</style>
<div class="top">
    <div class="user_top user_project">
        <i>
            <?php
            if (intval($level) > 1) {
                echo '<a href="manage.php">' . $userInfo['groupname'] . '</a>';
            } else {
                echo $userInfo['groupname'];
            } ?>
            UID:<?php echo $id; ?>
        </i>
        <div class="user_top_conn"><img src="<?php echo $userInfo['headimgurl'] ?>"/>
            <p><?php echo $userInfo['truename'] ?></p>
            <?php if (intval($level) < 5) { ?><a class="user_link" href="member.php">返回用户</a><?php } ?>
        </div>
    </div>
</div>
<!--工单列表开始-->

<!--工单详情开始-->
<div class="main">
    <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>工程信息
        <?php if ($uid == $pmid && $jindu2 == 4) { ?>
            <a href="projectOver.php?projectid=<?php echo $row['id'] ?>">
                <span style="float: right;text-align: right;color: red">提交工程竣申请</span></a>
        <?php } ?>
    </div>
    <div class="weui-form-preview">
        <div class="weui-form-preview__bd">
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">工程编号：</label>
                <span class="weui-form-preview__value">
		<?php
        if (!empty($row['poster'])) {
            echo '<i class="fa fa-smile-o blue "></i>';
        }
        if (!empty($row['openid'])) {
            echo '<i class="fa fa-weixin green"></i>';
        }
        ?>
        <?php echo date("Ymd", $row['post_time']) . "-" . $row['id'] ?>
        </span>
            </div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">工程名称：</label>
                <span class="weui-form-preview__value"><?php echo $row['projectname'] ?></span></div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">甲方：</label>
                <span class="weui-form-preview__value"><?php echo $row['school'] ?></span></div>
            <?php if (!empty($row['truename'])) { ?>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">联系人：</label>
                    <span class="weui-form-preview__value"><?php echo $row['truename'] ?></span></div>
            <?php } ?>
            <?php if (!empty($row['mobile'])) { ?>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">电话：</label>
                    <span class="weui-form-preview__value"><a href="tel:<?php echo $row['mobile'] ?>"><i class="fa fa-mobile"><?php echo $row['mobile'] ?></a></i></span>
                </div>
            <?php } ?>
            <?php if (!empty($row['mobile'])) { ?>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">工程位置：</label>
                    <span class="weui-form-preview__value" id="daohang" data-projectid="<?php echo $row['id'] ?>"><i class="fa fa-map-marker"><?php echo $row['address'] ?></i></span>
                </div>
            <?php } ?>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">服务类型：</label>
                <span class="weui-form-preview__value"><i class="fa  fa-drivers-license-o red"></i> <?php echo getRepairMode($row['apply_device']) ?></span>
            </div>


            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">施工要求：</label>
                <span class="weui-form-preview__value"><?php echo $row['content'] ?></span></div>


            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label red">项目经理：</label>
                <span class="weui-form-preview__value">

            <?php if (!empty($row['pmid'])) {
                echo ' <i class="fa  fa-user-o red"></i>      ' . getManage($row['pmid']);
            }
            ?>
        
        </span></div>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label blue">项目经理2：</label>
                <span class="weui-form-preview__value">

            <?php if ($row['pmid2'] > 0) {
                echo ' <i class="fa  fa-user-o red"></i>      ' . getManage($row['pmid2']);
            }
            ?>
                    <?php if ($isadmin == 1 || $uid == $pmid) { ?>
                        <a href="projectPm2.php?projectid=<?php echo $row['id'] ?>" class="weui-btn weui-btn_mini weui-btn_primary">设置</a>
                    <?php } ?>

        </span></div>


            <?php if (!empty($row['begintime'])) { ?>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">工程周期：</label>
                    <span class="weui-form-preview__value"><i class="fa fa-play green"></i> <?php echo date("Y-m-d ", $row['begintime']) . "
		<br/><i  class=' red fa  fa-stop'></i>     " . date("Y-m-d", $row['endtime']) ?></span></div>
            <?php } ?>
            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">施工图纸</label>
                <div class="weui-uploader">
                    <div class="weui-uploader__bd">
                        <ul class="weui-uploader__files uploaderFiles_item_log" id="pic_uploaderFiles">
                            <?php echo $pic_lists; ?>
                        </ul>
                    </div>
                </div>
            </div>


            <div class="weui-form-preview__item">
                <label class="weui-form-preview__label">施工计划</label>
                <div class="weui-uploader">
                    <div class="weui-uploader__bd">
                        <ul class="weui-uploader__files uploaderFiles_item_log" id="pic_uploaderFiles">
                            <?php echo $plan_pic_lists; ?>
                        </ul>
                    </div>
                </div>
            </div>
            

            <div class="sub_btn"></div>
            <input type="hidden" name="pmid" id="pmid" value="<?php echo $pmid; ?>">
            <input type="hidden" id="latitude" name="latitude">
            <input type="hidden" id="longitude" name="longitude">
            <input type="hidden" id="accuracy" name="accuracy">
            <input type="hidden" id="address" name="address">
            <input type="hidden" id="address_name" name="address_name" value="">
        </div>
    </div>
</div>
<?php if ($uid == $pmid && $jindu2 <= 4) {?>
    <div class="panel panel-info">
        <div class="panel-heading">
            <h3 class="panel-title">工程管理</h3>
        </div>
        <div class="panel-body">
            <a href="projectReport.php?projectid=<?php echo $projectid;?>" class="btn btn-success">项目周进度汇报</a>
            <?php
            //如果没有签到记录可以上传施工计划
            $order_qiandao=$dosql->GetOne("select `id` from `#@__project_log` WHERE orderid='$projectid'  and signIn=1 ");
            if(is_array($order_qiandao) && isset($order_qiandao['id']) ){

            }else{
                if($project_plan==""){
                    echo '<a href="projectPlan.php?projectid='.$projectid.'" class="btn btn-danger">项目施工计划</a>';
                }

            }
            ?>
        </div>
    </div>
<?php } ?>


<!-- 验收日期 -->
<?php if ($jindu2 > 5) {
    ?>
    <div class="main mb-2">
        <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>工程发起验收流程信息</div>
        <div class="weui-form-preview">
            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">验收日期</label>
                    <span class="weui-form-preview__value"><?php echo date("Y-m-d", $row['oktime']) . "~" . date("Y-m-d", $row['oktime2']); ?></span>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">验收要求备注</label>
                    <div class="weui-uploader">
                        <div class="weui-uploader__bd">
                            <?php echo $row['checkbook'] ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php } ?>

<!--施工日志-->

<div class="panel panel-default">
    <div class="panel-heading liucheng"><i class="fa fa-exchange" aria-hidden="true"></i>项目流程</div>
    <div class="panel-body text-warning">
        <div class="timeline2-centered">

            <!-- 工单流水-->
            <?php
            $i = 1;
            $dosql->Execute("SELECT * FROM `#@__project_log` WHERE orderid='$projectid'  ORDER BY id desc");
            while ($row2 = $dosql->GetArray()) {
                $bg_color = 'bg-info';
                if ($i == 1) {
                    $bg_color = 'bg-success';
                }
                ?>
                <div class="timeline2-entry">
                    <div class="timeline2-entry-inner">
                        <div class="timeline2-icon <?php echo $bg_color; ?>">
                            <i class="fa fa-arrow-up" aria-hidden="true"></i></div>
                        <div class="timeline2-label">
                            <h2>
                                <a href="#"><strong><?php echo $row2['op'] ?></strong></a>
                                <div class="text-danger mt-2">
                                    <span class="label label-success list-datetime"><?php echo date("Y-m-d H:i:s", $row2['op_time']) ?></span>
                                </div>
                            </h2>
                            <?php if ($row2['pmid'] > 0) { ?>
                                <div class="text-info mt-2 renyuan">
                                    项目经理：<span class="text-danger callPhone"><i class="fa fa-phone" aria-hidden="true"></i> <?php echo getManage($row2['pmid']); ?></span><br>
                                    <?php
                                    if ($row2['manageid'] != "") {
                                        echo "施工人员：" . GetMembersName($row2['manageid']);
                                    }
                                    ?>

                                </div>
                            <?php } ?>

                            <?php
                            if (strlen($row2['picurls']) > 20) {
                                echo '<div class="mt-2 mb-2 row picarr uploaderFiles_item_log">';
                                $picarr = json_decode($row2['picurls'], true);
                                foreach ($picarr as $v) {
                                    echo '<div class="col-xs-6 mb-2"><img data-bigsrc=' . $v . '  src=' . $v . '?x-oss-process=style/w200></div>';

                                }
                                echo '</div>';
                            }


                            ?>

                            <div class="mt-2 mb-2">
                                <?php echo $row2['remark'] ?>
                            </div>

                            <?php if ($row2['address_name'] != '') { ?>
                                <div class="openMapItem" data-address="<?php echo $row2['address_name']; ?>" data-addressinfo="<?php echo $row2['address']; ?>" data-lat="<?php echo $row2['latitude'] ?>" data-lng="<?php echo $row2['longitude'] ?>">
                                    <div class="text-success address_info">
                                        地点：<?php echo $row2['address_name']; ?>
                                        <i class="fa fa-map-marker text-danger" aria-hidden="true"></i>
                                    </div>
                                    <div class="text-success address_info">
                                        位置：<?php echo $row2['address']; ?>
                                    </div>
                                </div>
                            <?php } ?>
                        </div>
                    </div>
                </div>


                <?php
                $i++;
            }
            ?>
            <!-- 工单流水-->

        </div>

    </div>
</div>


<!--项目施工签到 开始 -->
<?php if ($jindu2 == 4 && $signIn == 0 && ($uid == $pmid || $uid == $pmid2)) { ?>
    <div class="main">
        <div class="weui-cells__title "><i class="fa fa-id-card-o" aria-hidden="true"></i> 项目签到：</div>
        <!--完修模块-->
        <form name="form" id="form" method="post" action="">
            <div class="weui-cells__title">工作类型 <span class="red">*</span></div>

            <div class="weui-cell weui-cells_radio order_do_type">

                <?php
                $dosql->Execute("SELECT * FROM `#@__task` WHERE `checkinfo`='1' and is_delete=0  and classid in (6,7) order by orderid ASC", 10);
                while ($row_project_type = $dosql->GetArray(10)) {
                    echo '<label class="weui-cell weui-check__label" for="x1' . $row_project_type['id'] . '">
                    <div class="weui-cell__bd">
                        <p>' . $row_project_type['title'] . '  ' . $row_project_type['value'] . '   ' . $row_project_type['unit'] . '</p>
                    </div>
                    <div class="weui-cell__ft">
                        <input type="radio" class="weui-check"  name="apply_device" value="' . $row_project_type['id'] . '" id="x1' . $row_project_type['id'] . '" >
                        <span class="weui-icon-checked"></span>
                    </div>
                </label>';

                }
                ?>

            </div>


            <div class="weui-cells weui-cells_form" style="margin-top: 0">
                <div class="weui-cells__title">本次服务工程师：<span class="red">*</span></div>
                <div class="weui-cells ">
                    <div id="gongchengshi">
                        <div class="weui-cells weui-cells_checkbox m_list">
                            <?php
                            $dosql->Execute("SELECT * FROM  `#@__user`  WHERE `level`=3   ORDER BY id asc", 8);
                            while ($row3 = $dosql->GetArray(8)) {

                                echo '<label class="weui-cell weui-check__label" for="s' . $row3['id'] . '">
                            <div class="weui-cell__hd">
                              <input type="checkbox" class="weui-check" value="' . $row3['id'] . '" name="manageid" id="s' . $row3['id'] . '" >
                              <i class="weui-icon-checked"></i>
                            </div>
                            <div class="weui-cell__bd">
                              <p>' . $row3['truename'] . '</p>
                            </div>
                          </label>';


                            }
                            ?>
                        </div>
                    </div>
                    <div class="weui-cells__title">本次服务工程师：</div>
                    <div id="gongchengshi2">

                        <div class="weui-cells weui-cells_checkbox m_list">
                            <?php
                            $dosql->Execute("SELECT * FROM  `#@__user`  WHERE `level`=4   ORDER BY id asc", 8);
                            while ($row3 = $dosql->GetArray(8)) {

                                echo '<label class="weui-cell weui-check__label" for="s' . $row3['id'] . '">
                            <div class="weui-cell__hd">
                              <input type="checkbox" class="weui-check" value="' . $row3['id'] . '" name="manageid" id="s' . $row3['id'] . '" >
                              <i class="weui-icon-checked"></i>
                            </div>
                            <div class="weui-cell__bd">
                              <p>' . $row3['truename'] . '</p>
                            </div>
                          </label>';


                            }
                            ?>
                        </div>
                    </div>

                    <input type="hidden" name="manageids" id="manageids" value=""/>
                </div>
                <!--上传 开始-->
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <div class="weui-uploader">
                            <div class="weui-uploader__hd">
                                <p class="weui-uploader__title">图片上传<span class="red">*</span></p>
                                <div class="weui-uploader__info">0/9</div>
                            </div>

                            <div class="weui-uploader__bd">
                                <ul class="weui-uploader__files" id="uploaderFiles">

                                </ul>
                                <div class="weui-uploader__input-box">
                                    <input id="uploaderInput" class="weui-uploader__input">
                                    <input type="hidden" name="picfiles" id="picfiles">
                                </div>
                            </div>
                            <div id="tip" class=" alert-error manage-alert manage-alert-error">请上传场地照片，人员照片</div>
                        </div>
                    </div>
                </div>
                <!--上传 结束-->

                <div class="weui-cells__title">施工备注：</div>
                <div class="weui-cells ">
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea class="content" name="content2" id="content2" placeholder="请输入文本"
                                      rows="3"></textarea>
                            <div class="weui-textarea-counter"><span>0</span>/200</div>
                        </div>
                    </div>
                </div>
            </div>
            <!--上传 开始-->

            <!--上传 结束-->
            <input type="hidden" name="action" id="action" value="add"/>

        </form>
        <!-- 完修模块-->
        <div class="sub_btn"><a href="javascript:;" class="weui-btn weui-btn_primary"
                                onclick="signIn(<?php echo $projectid ?>);return false;">项目签到</a></div>
        <div class="clear"></div>
    </div>
    <!--项目施工签到 结束-->
<?php } ?>

<div class="row">
    <div class="col-xs-12"> <?php echo $op_str ?> </div>
</div>


<!--项目施工签退 开始 -->
<?php if ($jindu2 == 4 && $signIn == 1 && ($uid == $pmid || $uid == $pmid2)) { ?>
    <div class="main">
        <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>本次施工签退：</div>
        <!--完修模块-->
        <form name="form" id="form" method="post" action="">
            <div class="weui-cells weui-cells_form">
                <div class="weui-cells__title">本次服务工程师：<span class="red">*</span></div>
                <div class="weui-cells ">
                    <div id="gongchengshi" class="alert alert-success" role="alert">

                        <?php
                        $reg_manageid = explode(",", $old_manageid);
                        foreach ($reg_manageid as $key => $val) {
                            echo ' <i class="fa  fa-user-o green"></i>      ' . getManage($val) . '    ';
                        }
                        ?>
                    </div>

                </div>
                <!--上传 开始-->
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <div class="weui-uploader">
                            <div class="weui-uploader__hd">
                                <p class="weui-uploader__title">图片上传<span class="red">*</span></p>
                                <div class="weui-uploader__info">0/9</div>
                            </div>

                            <div class="weui-uploader__bd">
                                <ul class="weui-uploader__files" id="uploaderFiles">

                                </ul>
                                <div class="weui-uploader__input-box">
                                    <input id="uploaderInput" class="weui-uploader__input">
                                    <input type="hidden" name="picfiles" id="picfiles">
                                </div>
                            </div>
                            <div id="tip" class=" alert-error manage-alert manage-alert-error">请上传场地照片，人员照片，本次施工增量照片
                            </div>
                        </div>
                    </div>
                </div>
                <!--上传 结束-->

                <div class="weui-cells__title">施工备注：</div>
                <div class="weui-cells ">
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea class="content" name="content2" id="content2" placeholder="请输入文本"
                                      rows="3"></textarea>
                            <div class="weui-textarea-counter"><span>0</span>/200</div>
                        </div>
                    </div>
                </div>
            </div>
            <!--上传 开始-->

            <!--上传 结束-->
            <input type="hidden" name="action" id="action" value="add"/>

        </form>
        <!-- 完修模块-->
        <div class="sub_btn"><a href="javascript:;" class="weui-btn weui-btn_warn"
                                onclick="qiantui(<?php echo $projectid ?>);return false;">本次施工签退</a></div>
        <div class="clear"></div>
    </div>
    <!--项目施工签退 结束-->
<?php } ?>


<div class="sub_btn"></div>


<!-- 验收日期 -->
<?php if ($jindu2 > 5) {
    ?>
    <div class="main">
        <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>工程发起验收流程信息</div>
        <div class="weui-form-preview">
            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">验收日期</label>
                    <span class="weui-form-preview__value"><?php echo date("Y-m-d", $row['oktime']) . "~" . date("Y-m-d", $row['oktime2']); ?></span>
                </div>
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">验收要求备注</label>
                    <div class="weui-uploader">
                        <div class="weui-uploader__bd">
                            <?php echo $row['checkbook'] ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
<?php } ?>

<!--工单详情结束-->
<?php if ($jindu2 > 6) {

    ?>
    <div class="main">
        <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>验收通过信息</div>
        <div class="weui-form-preview">
            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">通过时间</label>
                    <span class="weui-form-preview__value"><?php echo date("Y-m-d H:i:s", $row['checktime']); ?></span>
                </div>
            </div>
            <div class="weui-form-preview__bd">
                <div class="weui-form-preview__item">
                    <label class="weui-form-preview__label">备注</label>
                    <span class="weui-form-preview__value"><?php echo $row['checkcontent']; ?></span></div>
            </div>
        </div>
    </div>
<?php } ?>

<!--项目 发起验收 开始 -->
<?php if ($jindu2 == 5 && $isadmin == 1) { ?>
    <div class="main">
        <div class="weui-cells__title"><i class="fa fa-id-card-o" aria-hidden="true"></i>设置工程验收日期：</div>
        <!--完修模块-->
        <form name="form" id="form" method="post" action="">

            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label text-warning">开始验收：</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="form-control" type="text" name="date" id="date" value="<?php echo date("Y-m-d") ?>">
                    <input type="hidden" name="begintime" id="begintime" value="<?php echo date("Y-m-d") ?>">
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__hd">
                    <label class="weui-label text-warning">结束验收：</label>
                </div>
                <div class="weui-cell__bd">
                    <input class="form-control" type="text" name="date2" id="date2" value="<?php echo date("Y-m-d", time() + 432000) ?>">
                    <input type="hidden" name="endtime" id="endtime" value="<?php echo date("Y-m-d", time() + 432000) ?>">

                </div>
            </div>

            <div class="weui-cells__title">验收要求备注：</div>
            <div class="weui-cells ">
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                            <textarea class="content" name="checkbook" id="checkbook" placeholder="请输入文本"
                                      rows="3"></textarea>
                        <div class="weui-textarea-counter"><span>0</span>/200</div>
                    </div>
                </div>
            </div>
    </div>
    <!--上传 开始-->

    <!--上传 结束-->
    <input type="hidden" name="action" id="action" value="add"/>

    </form>
    <!-- 完修模块-->
    <div class="sub_btn"><a href="javascript:;" class="weui-btn weui-btn_warn"
                            onclick="kaishiyanshou(<?php echo $projectid ?>);return false;">发起验收流程</a></div>
    <div class="clear"></div>
    </div>
    <!--项目施工签退 结束-->
<?php } ?>


<!--项目 发起验收 开始 -->
<?php if ($jindu2 == 6 && ($isadmin == 1 || $pmid == $uid)) { ?>
    <div class="main">
        <div class="weui-cells__title red"><i class="fa fa-id-card-o" aria-hidden="true"></i>确认验收通过：</div>
        <!--完修模块-->
        <form name="form" id="form" method="post" action="">

            <div class="weui-cells weui-cells_form">
                <div class="weui-cells__title">本次服务工程师：<span class="red">*</span></div>
                <div class="weui-cells ">

                    <div class="weui-cells weui-cells_checkbox m_list">
                        <?php
                        $dosql->Execute("SELECT * FROM  `#@__user`  WHERE `level`=3   ORDER BY id asc", 8);
                        while ($row3 = $dosql->GetArray(8)) {

                            echo '<label class="weui-cell weui-check__label" for="s' . $row3['id'] . '">
                            <div class="weui-cell__hd">
                              <input type="checkbox" class="weui-check" value="' . $row3['id'] . '" name="manageid" id="s' . $row3['id'] . '" >
                              <i class="weui-icon-checked"></i>
                            </div>
                            <div class="weui-cell__bd">
                              <p>' . $row3['truename'] . '</p>
                            </div>
                          </label>';


                        }
                        ?>
                    </div>
                    <input type="hidden" name="manageids" id="manageids" value=""/>

                </div>
                <!--上传 开始-->
                <div class="weui-cell">
                    <div class="weui-cell__bd">
                        <div class="weui-uploader">
                            <div class="weui-uploader__hd">
                                <p class="weui-uploader__title">图片上传</p>
                                <div class="weui-uploader__info">0/9</div>
                            </div>

                            <div class="weui-uploader__bd">
                                <ul class="weui-uploader__files" id="uploaderFiles">

                                </ul>
                                <div class="weui-uploader__input-box">
                                    <input id="uploaderInput" class="weui-uploader__input">
                                    <input type="hidden" name="picfiles" id="picfiles">
                                </div>
                            </div>

                        </div>
                    </div>
                </div>
                <!--上传 结束-->

                <div class="weui-cells__title">通过备注：</div>
                <div class="weui-cells ">
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea class="content" name="content2" id="content2" placeholder="请输入文本"
                                      rows="3"></textarea>
                            <div class="weui-textarea-counter"><span>0</span>/200</div>
                        </div>
                    </div>
                </div>
            </div>

    </div>
    <!--上传 开始-->

    <!--上传 结束-->
    <input type="hidden" name="action" id="action" value="add"/>

    </form>
    <!-- 完修模块-->
    <div class="sub_btn"><a href="javascript:;" class="weui-btn weui-btn_warn"
                            onclick="yanshoutongguo(<?php echo $projectid ?>);return false;">确认验收通过</a></div>
    <div class="clear"></div>
    </div>
    <!--项目施工签退 结束-->
<?php } ?>

<div class="clear"></div>
<div class="sub_btn"></div>
<script src="lib/jquery-2.1.4.js"></script>
<script src="lib/fastclick.js"></script>
<script src="js/layer/layer.js"></script>
<script src="https://res.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
<script>
    $(function () {
        FastClick.attach(document.body);


        $("#date").calendar({
            minDate: '<?php echo date("Y-m-d", time() - 86400)?>',
            onChange: function (p, values, displayValues) {
                console.log(values);
                $("#begintime").val(values[0])

                var endTime = $("#endtime").val();
                var endTime = endTime + " 23:59:59";
                var beginTime = values[0];
                var d1 = new Date(beginTime.replace(/\-/g, "\/"));
                var d2 = new Date(endTime.replace(/\-/g, "\/"));
                console.log(d1);
                if (beginTime != "" && endTime != "" && d1 > d2) {
                    layer.msg("开始时间不能大于结束时间！");
                    return false;
                }
            }
        });
        $("#date2").calendar({
            minDate: '<?php echo date("Y-m-d", time() - 86400)?>',
            onChange: function (p, values, displayValues) {
                console.log(values);
                $("#endtime").val(values[0]);
                var beginTime = $("#begintime").val();
                var endTime = values[0];
                var endTime = endTime + " 23:59:59";
                var d1 = new Date(beginTime.replace(/\-/g, "\/"));
                var d2 = new Date(endTime.replace(/\-/g, "\/"));
                console.log(d1);
                if (beginTime != "" && endTime != "" && d1 >= d2) {
                    layer.msg("开始时间不能大于结束时间！");
                    return false;
                }
            }
        });


        //选择工程师
        $("input[name='manageid']").change(function () {
            // 是否选择工程师
            checkids = [];
            ids = "";
            $("input[name='manageid']:checked").each(function (i) {
                checkids[i] = $(this).val();
            });

            ids = checkids.join(",");
            console.log(ids);
            //重新给隐藏参数赋值
            $("#manageids").val(ids);
            if (checkids.length == 0) {
                $.toast("至少选择一位工程师", "forbidden");
                return false;
            }
        });

    });
    /*
     * 注意：
     * 1. 所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。
     * 2. 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
     * 3. 常见问题及完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
     *
     * 开发中遇到问题详见文档“附录5-常见错误及解决办法”解决，如仍未能解决可通过以下渠道反馈：
     * 邮箱地址：weixin-open@qq.com
     * 邮件主题：【微信JS-SDK反馈】具体问题
     * 邮件内容说明：用简明的语言描述问题所在，并交代清楚遇到该问题的场景，可附上截屏图片，微信团队会尽快处理你的反馈。
     */
    wx.config({
        debug: false,
        appId: '<?php echo $signPackage["appId"];?>',
        timestamp: <?php echo $signPackage["timestamp"];?>,
        nonceStr: '<?php echo $signPackage["nonceStr"];?>',
        signature: '<?php echo $signPackage["signature"];?>',
        jsApiList: [
            // 所有要调用的 API 都要加到这个列表中
            'onMenuShareTimeline',
            'onMenuShareAppMessage',
            'onMenuShareQQ',
            'onMenuShareWeibo',
            'openAddress',
            'chooseImage',
            'previewImage',
            'uploadImage',
            'downloadImage',
            'openLocation',
            'getLocation'
        ]
    });
    wx.ready(function () {
        //预览图片
        var images = $("#pic_uploaderFiles").find("img");

        var imgPaths = [];
        images.each(function () {
            imgPaths.push(this.src);
        });
        $("#pic_uploaderFiles").on("click", function () {
            current = imgPaths[0];
            console.log(current);
            wx.previewImage({
                current: current,
                urls: imgPaths
            });
        });


        var images_over = $("#uploaderFiles_over").find("img");

        var imgPaths_over = [];
        images_over.each(function () {
            imgPaths_over.push(this.src);
        });
        $("#uploaderFiles_over").on("click", function () {
            current_over = imgPaths_over[0];
            wx.previewImage({
                current: current_over,
                urls: imgPaths_over
            });
        });


        $(".uploaderFiles_item_log").on("click", function (e) {
            var images = $(this).find("img");
            var imgPaths = [];
            images.each(function () {
                imgPaths.push(this.dataset.bigsrc);
            });
            console.log(imgPaths);
            current = imgPaths[0];
            wx.previewImage({
                current: current,
                urls: imgPaths
            });

        });

        $(".openMapItem").on("click", function (e) {
            console.log("点击导航");

            var address = e.currentTarget.dataset.address;
            var addressinfo = e.currentTarget.dataset.addressinfo;
            var longitude = e.currentTarget.dataset.lng;
            var latitude = e.currentTarget.dataset.lat;

            wx.openLocation({
                latitude: latitude, // 纬度，浮点数，范围为90 ~ -90
                longitude: longitude, // 经度，浮点数，范围为180 ~ -180。
                name: address, // 位置名
                address: addressinfo, // 地址详情说明
                scale: 16, // 地图缩放级别,整型值,范围从1~28。默认为最大

            });

        });


        //打开导航
        $("#daohang").on("click", function () {
            var projectid = $(this).data("projectid");
            $.ajax({
                type: 'POST',
                url: "dingwei.php",
                data: {op: 'dingwei', 'id': projectid},
                dataType: 'JSON',
                success: function (result) {
                    console.log(result);
                    if (result.errno == 0) {
                        console.log(result.msg);
                        if (result.msg === "ok") {
                            wx.openLocation({
                                latitude: result.data.latitude, // 纬度，浮点数，范围为90 ~ -90
                                longitude: result.data.longitude, // 经度，浮点数，范围为180 ~ -180。
                                name: result.data.school, // 位置名
                                address: result.data.address, // 地址详情说明
                                scale: result.data.accuracy, // 地图缩放级别,整形值,范围从1~28。默认为最大

                            });
                        } else {
                            $.alert("获取位置失败，客户没有进行定位", "温馨提示");
                        }
                    }
                }
            });
        })
        //获取gps信息
        wx.getLocation({
            type: 'gcj02', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
            success: function (res) {
                var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
                $("#latitude").val(latitude);
                var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
                $("#longitude").val(longitude);
                var speed = res.speed; // 速度，以米/每秒计
                var accuracy = res.accuracy; // 位置精度
                $("#accuracy").val(accuracy);
                if (latitude != '0.0') {
                    $.ajax({
                        url: "getMap.php?l=" + latitude + "&w=" + longitude,
                        type: "GET",
                        timeout: 2000,
                        dataType: "json",
                        success: function (data) {
                            console.log('ok');
                            var gps_address = data.result.address;
                            var address_name = data.result.formatted_addresses.recommend;
                            //alert(gps_address);
                            $("#address").val(gps_address);
                            $("#address_name").val(address_name);
                        },
                        error: function (data) {
                            console.log('error');

                        }
                    });
                } else {
                    $.alert("请把gps开启为当前地点", " 温馨提示");
                }
            },
            cancel: function (res) {
                $.alert("你拒绝授权获取地理位置，我们的工程师无法快速定位。时效性可能会延时，请谅解", " 温馨提示");
            }

        });


        //打开相册
        var images = {
            localId: [],
            serverId: []
        };
        var filepaths = [];
        document.querySelector('#uploaderInput').onclick = function () {
            wx.chooseImage({
                count: 9, // 默认9
                sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
                sourceType: ['camera'], // 可以指定来源是相册还是相机，默认二者都有
                success: function (res) {
                    var picurls = res.localIds;
                    var uploadCount = 0;
                    var pic_length = res.localIds.length;
                    var m = 0;
                    var upload = function () {
                        wx.uploadImage({
                            localId: picurls[uploadCount],
                            success: function (res) {
                                //如果还有照片，继续上传
                                var serverId = res.serverId; // 返回图片的服务器端ID
                                console.log(serverId);
                                $.ajax({
                                    type: 'POST',
                                    url: "getFile.php",
                                    data: {serverId: serverId},
                                    dataType: 'JSON',
                                    success: function (result) {
                                        if (result.errno == 0) {
                                            console.log(result.msg);
                                            if (result.msg === "ok") {
                                                filepaths.push(result.filename);
                                                $("#picfiles").val(filepaths);
                                                $("#uploaderFiles").append('<li class="weui-uploader__file" style="background-image:url(' + result.filename + ')"></li>');
                                            } else {
                                                $.alert("上传失败<br/> 请联系管理员！", "温馨提示");
                                            }
                                        }
                                    }
                                });
                                uploadCount++;
                                if (uploadCount < pic_length) {
                                    upload();
                                }
                            }
                        });
                    }
                    upload();
                }
            });
        }
        //


    })


    function jiedan(id) {
        var pmid = $("#pmid").val();
        var latitude = $("#latitude").val();
        var longitude = $("#longitude").val();
        var accuracy = $("#accuracy").val();
        var address = $("#address").val();
        var address_name = $("#address_name").val();
        // var picfiles = $("#picfiles").val();
        // console.log(picfiles);
        if (latitude !== "") {
            $.ajax({
                type: 'POST',
                url: "project_do.php",
                data: {
                    id: id,
                    op: 'jiedan',
                    'pmid': pmid,
                    'latitude': latitude,
                    'longitude': longitude,
                    'accuracy': accuracy,
                    'address': address,
                    'address_name': address_name,
                    // 'picfiles': picfiles
                },
                dataType: 'JSON',
                success: function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        console.log(result.msg);
                        $("#jiedan_btn").hide();
                        $.toast("接单成功", function () {
                            window.location.href = location.href;
                        });
                    } else {
                        $.alert(result.msg);
                    }
                }
            });
        } else {
            $.alert("获取不到位置信息", "温馨提示");
        }
    }


    function chedan(id) {
        var pmid = $("#pmid").val();
        var latitude = $("#latitude").val();
        var longitude = $("#longitude").val();
        var accuracy = $("#accuracy").val();
        var address = $("#address").val();
        var address_name = $("#address_name").val();
        // var picfiles = $("#picfiles").val();
        // console.log(picfiles);
        if (latitude !== "") {
            $.ajax({
                type: 'POST',
                url: "project_do.php",
                data: {
                    id: id,
                    op: 'chedan',
                    'pmid': pmid,
                    'latitude': latitude,
                    'longitude': longitude,
                    'accuracy': accuracy,
                    'address': address,
                    'address_name': address_name,
                    // 'picfiles': picfiles
                },
                dataType: 'JSON',
                success: function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        console.log(result.msg);
                        $("#jiedan_btn").hide();
                        $.toast(result.msg, function () {
                            window.location.href = location.href;
                        });
                    } else {
                        $.alert(result.msg);
                    }
                }
            });
        } else {
            $.alert("获取不到位置信息", "温馨提示");
        }
    }

    // 签到
    function signIn(id) {
        var pmid = $("#pmid").val();
        var latitude = $("#latitude").val();
        var longitude = $("#longitude").val();
        var accuracy = $("#accuracy").val();
        var address = $("#address").val();
        var address_name = $("#address_name").val();
        var content2 = $("#content2").val();
        console.log(content2);
        var manageids = $("#manageids").val();
        var picfiles = $("#picfiles").val();
        var apply_device = $('input[name="apply_device"]:checked').val(); //工作类型
        console.log(apply_device);
        if (apply_device == "" || apply_device == undefined) {
            $.alert("请选择工作类型", "温馨提示");
            return false;
        }
        if (manageids.length == 0) {
            $.alert("请选择工程师", "温馨提示");
            return false;
        }
        if (picfiles.length == 0) {
            $.alert("请上传照片", "温馨提示");
            return false;
        }

        if (latitude !== "") {
            $.ajax({
                type: 'POST',
                url: "project_do.php",
                data: {
                    id: id,
                    op: 'signIn',
                    'pmid': pmid,
                    'latitude': latitude,
                    'longitude': longitude,
                    'accuracy': accuracy,
                    'address': address,
                    'address_name': address_name,
                    'remark': content2,
                    'manageids': manageids,
                    'picfiles': picfiles,
                    'apply_device': apply_device
                },
                dataType: 'JSON',
                success: function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        console.log(result.msg);

                        $.toast("签到成功", function () {
                            window.location.href = location.href;
                        });


                    } else {
                        $.alert(result.msg);
                    }
                }
            });
        } else {
            $.alert("获取不到位置信息", "温馨提示");
        }
    }


    // 签退
    function qiantui(id) {
        var pmid = $("#pmid").val();
        var latitude = $("#latitude").val();
        var longitude = $("#longitude").val();
        var accuracy = $("#accuracy").val();
        var address = $("#address").val();
        var address_name = $("#address_name").val();
        var content2 = $("#content2").val();
        console.log(content2);
        var picfiles = $("#picfiles").val();
        if (picfiles.length == 0) {
            $.alert("请上传照片", "温馨提示");
            return false;
        }

        if (latitude !== "") {
            $.ajax({
                type: 'POST',
                url: "project_do.php",
                data: {
                    id: id,
                    op: 'qiantui',
                    'pmid': pmid,
                    'latitude': latitude,
                    'longitude': longitude,
                    'accuracy': accuracy,
                    'address': address,
                    'address_name': address_name,
                    'remark': content2,
                    'picfiles': picfiles
                },
                dataType: 'JSON',
                success: function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        console.log(result.msg);
                        $.toast("签退成功", function () {
                            window.location.href = location.href;
                        });


                    } else {
                        $.alert(result.msg);
                    }
                }
            });
        } else {
            $.alert("获取不到位置信息", "温馨提示");
        }
    }


    function qiantui2(id) {
        console.log(id);
        $.ajax({
            url: "project_do.php",
            dataType: 'json',
            type: "post",
            data: {
                'op': 'getUser',
                'id': id
            },
            error: function () {
                console.log("提交失败");
            },
            success: function (res) {
                layer.open({
                    type: 1,
                    title: false,
                    skin: 'layui-layer-rim', //加上边框
                    area: ['300px', '400px'], //宽高
                    content: '<div  class="alert-mobile-box no-auth-code">\n' +
                        '                    <span class="ajax-error hide"></span>\n' +
                        '                    <div class="desc text-center"><h3>请选择签退的人员</h3><br><span style="color:darkred">选择后该人员将自动结算虚拟奖励,为了安全期间多个人员中途签退请分别签退</span></div>\n' +

                        '                    <div class="weui-cells weui-cells_checkbox">' + res.data + '</div>' +

                        '                    <div class="error-tip"></div>\n' +
                        '                    <span id="zhongtuqiantui" class="btn-submit" onclick="qiantui2_do(' + id + ')">提交</span>\n' +
                        '                    <div class="protocal">\n' +

                        '                    </div>\n' +
                        '                    <i class="close"><i>\n' +
                        '                </i></i></div>'
                });
            }
        })

    }


    // 签退
    function qiantui2_do(id) {
        var pmid = $("#pmid").val();
        var qiantuiren = $("input[name='qiantui2']:checked").val();
        console.log(qiantuiren)
        var latitude = $("#latitude").val();
        var longitude = $("#longitude").val();
        var accuracy = $("#accuracy").val();
        var address = $("#address").val();
        var address_name = $("#address_name").val();
        if (qiantuiren !== "") {
            $.ajax({
                type: 'POST',
                url: "project_do.php",
                data: {
                    id: id,
                    op: 'qiantui2',
                    'pmid': pmid,
                    'manageid': qiantuiren,
                    'latitude': latitude,
                    'longitude': longitude,
                    'accuracy': accuracy,
                    'address': address,
                    'address_name': address_name
                },
                dataType: 'JSON',
                success: function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        console.log(result.msg);
                        $("#zhongtuqiantui").hide();
                        $.toast("签到成功", function () {
                            window.location.href = location.href;
                        });


                    } else {
                        $.alert(result.msg);
                    }
                }
            });
        } else {
            $.alert("获取不到位置信息", "温馨提示");
        }
    }


    // 发起验收流程
    function kaishiyanshou(id) {

        var beginTime = $("#begintime").val();
        var endTime = $("#endtime").val();
        var endTime = endTime + " 23:59:59";
        var d1 = new Date(beginTime.replace(/\-/g, "\/"));
        var d2 = new Date(endTime.replace(/\-/g, "\/"));
        console.log(d1);
        if (beginTime != "" && endTime != "" && d1 > d2) {
            layer.msg("开始时间不能大于结束时间！");
            return false;
        }
        var checkbook = $("#checkbook").val();

        $.ajax({
            type: 'POST',
            url: "project_do.php",
            data: {
                id: id,
                op: 'addcheck',
                'beginTime': beginTime,
                'endTime': endTime,
                'checkbook': checkbook

            },
            dataType: 'JSON',
            success: function (result) {
                console.log(result);
                if (result.code == 0) {
                    console.log(result.msg);
                    $.toast(result.msg, function () {
                        window.location.href = location.href;
                    });


                } else {
                    $.alert(result.msg);
                }
            }
        });

    }

    //验收通过
    function yanshoutongguo(id) {
        var pmid = $("#pmid").val();
        var latitude = $("#latitude").val();
        var longitude = $("#longitude").val();
        var accuracy = $("#accuracy").val();
        var address = $("#address").val();
        var address_name = $("#address_name").val();
        var content2 = $("#content2").val();
        console.log(content2);
        var manageids = $("#manageids").val();
        var picfiles = $("#picfiles").val();

        if (manageids.length == 0) {
            $.alert("请选择工程师", "温馨提示");
            return false;
        }


        if (latitude !== "") {
            $.ajax({
                type: 'POST',
                url: "project_do.php",
                data: {
                    id: id,
                    op: 'checkok',
                    'pmid': pmid,
                    'latitude': latitude,
                    'longitude': longitude,
                    'accuracy': accuracy,
                    'address': address,
                    'address_name': address_name,
                    'remark': content2,
                    'manageids': manageids,
                    'picfiles': picfiles,
                    'apply_device': 37
                },
                dataType: 'JSON',
                success: function (result) {
                    console.log(result);
                    if (result.code == 0) {
                        console.log(result.msg);

                        $.toast(result.msg, function () {
                            window.location.href = location.href;
                        });


                    } else {
                        $.alert(result.msg);
                    }
                }
            });
        } else {
            $.alert("获取不到位置信息", "温馨提示");
        }
    }


</script>
<script src="js/jquery-weui.js"></script>
<?php require_once('footer.php'); ?>
